<template>
    <div class="app-container">
        <a-card class="box-card" :cardOpen="true">
            <div slot="header">
                <span>事件信息</span>
            </div>
            <HandleEventInfo ref="eventInfoRef" :event="eventInfo" />
        </a-card>
        <a-card class="box-card" :cardOpen="true" :style="{ marginTop: '15px' }" v-for="item in handles" :key="item.renderKey">
            <div slot="header">
                <span> {{ item.title }} {{ item.isOld == 0 ? "(当前)" : "(已停止处置)" }} </span>
            </div>
            <handle-detail-card :plan="item.planDetail" :handleId="parseInt(item.handleId)" :handleing="item.isOld == 0" />
        </a-card>
    </div>
</template>
<script>
import ACard from "@/views/components/a-card/card.vue";
import * as HandleApi from "@/api/response/handle.js";
import * as DrillApi from "@/api/drill/drill.js";
import HandleDetailCard from "./components/HandleDetailCard.vue";
import * as RescueApi from "@/api/rescue/rescue";
import HandleEventInfo from "../handle/module/HandleEventInfo.vue";
import { getHandleInfo } from "@/api/response/handleInfo";

export default {
    name: "HandleDetail",
    components: {
        ACard,
        HandleDetailCard,
        HandleEventInfo,
    },
    data() {
        return {
            dutyInfo: null,
            eventInfo: {},
            groups: [],
            currentGroup: {
                flowId: 1,
                flowTitle: "组建领导小组",
                roleList: [
                    {
                        deptId: 0,
                        userName: "测试",
                    },
                    {
                        deptId: 0,
                        userName: "测试",
                    },
                ],
            },
            responseLevelOption: [
                {
                    label: "Ⅰ级响应",
                    value: 1,
                },
                {
                    label: "Ⅱ级响应",
                    value: 2,
                },
                {
                    label: "Ⅲ级响应",
                    value: 3,
                },
                {
                    label: "Ⅳ级响应",
                    value: 4,
                },
            ],
            staffPickType: "",
            chiefName: "",
            activeScene: "",
            sceneTabs: [],
            hdInfoId: 0,
            drillPlanId: 0,
            drillGroups: [],
            handles: [],
            globalKey: 100,
            modelId: 0,
            infoId: 0,
        };
    },
    created() {},
    mounted() {
        this.hdInfoId = this.$route.query.hdInfoId;
        this.getHandleInfo();
    },
    methods: {
        getHandleInfo() {
            // 获取处置的基本信息
            getHandleInfo(this.hdInfoId).then(hdInfo => {
                if (hdInfo.data.infoId) {
                    RescueApi.getPlanEventInfo(hdInfo.data.infoId).then(res => {
                        this.eventInfo = res.data;
                    });
                }
            });
            HandleApi.handleEventInfo(this.hdInfoId).then(res => {
                let data = res.data;
                let handles = [];
                data.forEach(h => {
                    let level = this.responseLevelOption.find(val => val.value == h.responseLevel);
                    handles.push({
                        title: `${h.planDetail.planName} - ${level.label}`,
                        planDetail: h.planDetail,
                        handleId: h.handleId,
                        responseLevel: h.responseLevel,
                        isOld: h.isOld,
                    });
                });
                this.handles = handles;
            });
        },
    },
    beforeDestroy() {
        this.$bus.$emit("handle-detail-destroy");
    },
};
</script>
<style lang="scss" scoped>
.box-card {
    .change-response-level {
        padding: 0;
        margin-left: 15px;
    }
}
</style>
